package com.atguigu.gmall.web.all.controller;

import com.atguigu.gmall.feign.order.OrderFeignClient;
import com.atguigu.gmall.model.order.OrderInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author lsj
 * @create 2021-08-29 23:16
 */
@Controller
public class PayController {

    @Autowired
    OrderFeignClient orderFeignClient;

    /**
     * 去支付页
     * @param orderId
     * @return
     */
    @GetMapping("/pay.html")
    public String toPayPage(@RequestParam("orderId") Long orderId,
                            Model model){

        //
        OrderInfo orderById = orderFeignClient.getOrderById(orderId);

        model.addAttribute("orderInfo",orderById);
        //这个页面需要数据  id
        //页面需要 orderInfo:{id,totalAmount}
        return "payment/pay";
    }

    @GetMapping("/payment/success.html")
    public String toPaySuccessPage(){
        return "payment/success";
    }
}
